home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
cislib_a
/
ciolib.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-04-22
|
3KB
|
127 lines
(* CIOLib.i
________
(C) 1986 Erik C. Warren
Routines to access CIO calls.
Last Updated: 30 July, 1986
These routines are in the public
domain and may not be sold, except for
the price of the software media, with-
out the expressed, written permission
of the author. *)
FUNCTION Close(IOCB_Num: Integer): Integer;
BEGIN
Close:= 1;
IOCB_Num:= IOCB_Num * 16;
#A
stx _t
ldy #7
lda (_sp),y ;IOCB
tax
lda #12 ;close command
sta $342,x
jsr $e456 ;ciov
tya ;same as icsta
ldy #5
sta (_sp),y ;store in Close
ldx _t
#
END;(* Close *)
FUNCTION Open(IOCB_Num,Ax1,Ax2: Integer; VAR Dev: Device_String)
: Integer;
BEGIN
Open:= 1;
IOCB_Num:= IOCB_Num * 16;
(* stack: opn num ax1 ax2 dev
5 13 11 9 7 *)
#A
stx _t
ldy #13
lda (_sp),y ;IOCB
tax
lda #3 ;open command
sta $342,x
dey
dey ;11
lda (_sp),y ;icax1
sta $34a,x
dey
dey ;9
lda (_sp),y ;icax2
sta $34b,x
dey ;8
lda (_sp),y ;dev MSB
sta $345,x ;icbah
dey ;7
lda (_sp),y ;icbal
sta $344,x
jsr $e456 ;ciov
tya ;same as icsta
ldy #5
sta (_sp),y ;store in Open
ldx _t
#
END;(* Open *)
FUNCTION Get_Byte(IOCB_Num: Integer;
VAR GB: Integer)
: Integer;
VAR TB: Integer;
BEGIN
TB:= 0;
Get_Byte:= 1;
GB:= 0;
IOCB_Num:= IOCB_Num * 16;
(* stack: get num gb tb
7/8 11/12 9/10 5/6 *)
#A
stx _t
ldy #11
lda (_sp),y ;IOCB
tax
lda #7 ;get char command
sta $342,x
lda #$00 ;zero out the unused
sta $348,x ;store in accumulator
sta $349,x ;...after CIOV jump
jsr $e456
sty _t+1 ;hold temporarily
ldy #5
sta (_sp),y ;put byte in GB
lda _t+1 ;get status back
ldy #7
sta (_sp),y ;store in Get_Byte
ldx _t
#
GB:= TB
END;(* Get_Byte *)
FUNCTION Put_Byte(IOCB_Num: Integer;
PB: Integer)
: Integer;
BEGIN
Put_Byte:= 1;
IOCB_Num:= IOCB_Num * 16;
(* stack: put num pb
5 9 7 *)
#A
stx _t
ldy #9
lda (_sp),y ;IOCB
tax
lda #11 ;put char command
sta $342,x
lda #$00 ;zero out the unused
sta $348,x ;put from accumulator
sta $349,x
ldy #7
lda (_sp),y ;put PB in accumulator
jsr $e456
tya ;same as icsta
ldy #5
sta (_sp),y ;store in Put_Byte
ldx _t
#
END;(* Put_Byte *)